<template>
  <div class="wrapper">
    <source-list :sources=sources class="draft-source-list"
    @fetchSourceAbstracts="fetchSourceAbstracts"></source-list>
  </div>
</template>

<script>
import SourceList from '@/components/PublishedSourceList.vue';

  export default {
    components: {
      SourceList,
    },
    data() {
      return {
        sources: [],
        sourcePage: 0,
      }
    },
    methods: {
      fetchSourceAbstracts() {
        this.$fetch({
          name: 'source published',
          url: 'creator/manage/source/published',
          method: 'POST',
          data: {
            page: ++this.sourcePage
          }
        }).then(res => {
          if(res.data.success) {
            if(res.data.object) this.sources = this.sources.concat(res.data.object);
            else this.sourcePage--;
          } else {
            this.$alert({
              type: 'error',
              content: '获取文章失败'
            });
            this.sourcePage--;
          }
        }).catch(error => {
          this.$alert({
            type: 'error',
            content: '获取文章失败'
          });
          this.sourcePage--;
        })
      }
    },
  }
</script>

<style lang="less" scoped>
</style>